package tech.dongliang.common.response;

import lombok.Data;
import tech.dongliang.common.model.CommonModel;

@Data
public class CommonResponse<T> extends CommonModel {

    /**
     * 是否成功
     */
    private boolean success = false;
    /**
     * 返回数据
     */
    private T data;

    public static CommonResponse success(Object obj) {
        return create(obj, true);
    }

    public static CommonResponse error(Object obj) {
        return create(obj, false);
    }

    public static CommonResponse create(Object obj, boolean success) {
        CommonResponse response = new CommonResponse();
        response.setData(obj);
        response.setSuccess(success);
        return response;
    }
}
